﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace ModelViewer
{
    class ToolbarRenderer : ToolStripProfessionalRenderer
    {
        private Brush menuBackground = new SolidBrush(Color.FromArgb(56, 56, 56));
        private Pen borderPen = new Pen(Brushes.Black, 2);


        protected override void OnRenderItemBackground(ToolStripItemRenderEventArgs myMenu)
        {
            //if (!myMenu.Item.Selected)
            //    base.OnRenderMenuItemBackground(myMenu);

            //else
            //{
                Rectangle menuRectangle = new Rectangle(Point.Empty, myMenu.Item.Size);



                //Fill Color
                myMenu.Graphics.FillRectangle(menuBackground, menuRectangle);

                // Border Color
                myMenu.Graphics.DrawRectangle(Pens.Black, 1, 0, menuRectangle.Width - 2, menuRectangle.Height - 1);
            //}
        }

        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripButton tsb = e.Item as ToolStripButton;
            if (tsb == null)
            {
                base.OnRenderButtonBackground(e);
            }

            if (tsb.Checked)
            {
                Rectangle menuRectangle = new Rectangle(Point.Empty, e.Item.Size);

                //Fill Color
                e.Graphics.FillRectangle(menuBackground, menuRectangle);

                // Border Color
                e.Graphics.DrawRectangle(Pens.Red, 1, 0, menuRectangle.Width - 2, menuRectangle.Height - 1);
            }
            else if (e.Item.Selected)
            {
                Rectangle menuRectangle = new Rectangle(Point.Empty, e.Item.Size);



                //Fill Color
                e.Graphics.FillRectangle(menuBackground, menuRectangle);

                // Border Color
                e.Graphics.DrawRectangle(borderPen, 1, 0, menuRectangle.Width - 2, menuRectangle.Height - 1);
            }
            else
            {
                base.OnRenderButtonBackground(e);
            }
        }
    }
}
